package com.guigu.pd.oms.service.impl;

import com.guigu.pd.oms.entity.AddressRule;
import com.guigu.pd.oms.service.DroolsRulesService;

import java.math.BigDecimal;

/**
 * @author lizongyi
 * @date 2022/7/26
 * @Note
 */
public class DroolsRulesServiceImpl implements DroolsRulesService {
    //根据条件计算订单价格
    public String calcFee(AddressRule addressRule) {
        BigDecimal lost = new BigDecimal(addressRule.getTotalWeight()).subtract(new BigDecimal(addressRule.getFirstWeight()));
        lost = lost.setScale(0,BigDecimal.ROUND_DOWN);
        BigDecimal continuedFee = lost.multiply(new BigDecimal(addressRule.getContinuedFee()));
        return continuedFee.add(new BigDecimal(addressRule.getFirstFee())).toString();
    }
}
